#include "USART.h"
#include "TIMER_Init.h"
#include "DS3231_Init.h"
#include "ADS126x.h"
#include "stm32f4xx.h"
#include "I2C_Init.h"
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <math.h>


unsigned char UploadchTem[8];                                          //uchar 字符数组温度
unsigned char UploadchCond[8];                                         //uchar 字符数组电导率
unsigned char UploadchFreq[8];                                         //uchar 字符数组频率
unsigned char UploadchRes[8];//++++++++++++++++++                      //uchar 字符数组电阻
unsigned char chPre[8];
unsigned char chPreU[8];


static char *g_ppcMonth[12] =
{
    "Jan",
    "Feb",
    "Mar",
    "Apr",
    "May",
    "Jun",
    "Jul",
    "Aug",
    "Sep",
    "Oct",
    "Nov",
    "Dec"
};
char  Datetime[16];         //时间读写数组


void CLOCK_Init(void);
void GPIO_Init_Config(void);
void PowerControl(unsigned char state);
void SendData(void);
unsigned char *fdasc(float Input,unsigned char AsciiT[8]);
unsigned char *fdasc2(float Input,unsigned char AsciiT[7]);
unsigned char *fdascU(float Input,unsigned char AsciiT[7]);
unsigned char *fdasc3(float Input,unsigned char AsciiT[8]);
unsigned char *fdascR(double Input,unsigned char AsciiT[8]);
float abs1(float Num);
int32_t floattohex(float hex);


#define 			on 														1
#define 			off 													0




int main(void)
{
	SamMode = 2;
	USART_INIT();	//串口初始化
    Usart_SendString(DEBUG_USART,"11completed\r\n");
	GPIO_Init_Config();										//引脚初始化
	Usart_SendString(DEBUG_USART,"22completed\r\n"); 
	//CLOCK_Init();               							//系统时钟初始化
	//Usart_SendString(DEBUG_USART,(uint8_t *)"33completed\r\n");
	TIMER_Init_Config();									//定时器初始化
	Usart_SendString(DEBUG_USART,"44completed\r\n");
	I2C_EE_Init();											//I2C接口初始化
	Usart_SendString(DEBUG_USART,"55completed\r\n");
	DS3231_Init();											//时钟芯片初始化
	//delay_us(20);               					//初始化完成后延时20us等待初始化稳定
	Usart_SendString(DEBUG_USART,"Initialization is completed\r\n"); 

	

	
	PowerControl(on);
	Usart_SendString(DEBUG_USART,"66completed\r\n");
	

	
	Conductivity( );
	Temperature();
	Set_RTC();
	Read_RTC();
	//IIC_DS3231_WriteAll(2023,10,1,1,12,00,00);   //设置时间函数,实例为2023年10月1日12：00：00
    //IIC_DS3231_ReadAll();        //读取DS3231所有时间数据
	Usart_SendString(DEBUG_USART,"77completed\r\n");
	SendData( );
	//Sendtime();
	
	OperatingSampleInterval(1);
	
	gorun(1);
	
	while(1)
	{
		
		if(Goflag=1)
		{
            PowerControl(on);
            Temperature( );                         //温度测量程序，应加控制传感器通电的引脚上电，然后再开始测量，初始化引脚时应先掉电
            Conductivity( );                        //电导率测量程序
            SendData( );                            //发送数据不在循环里做，放入秒中断中去判断模式并执行
            Goflag = 0;
            PowerControl(off);
        }
	}
}	



//GPIO初始化
void GPIO_Init_Config(void)
{
	GPIO_InitTypeDef  GPIO_InitStructure;
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA
	|RCC_AHB1Periph_GPIOB
	|RCC_AHB1Periph_GPIOC
	|RCC_AHB1Periph_GPIOD
	|RCC_AHB1Periph_GPIOG,ENABLE);
	GPIO_InitStructure.GPIO_Pin=GPIO_Pin_6;
	GPIO_InitStructure.GPIO_Mode=GPIO_Mode_OUT;
	GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_UP;
	GPIO_InitStructure.GPIO_OType=GPIO_OType_PP;
	GPIO_InitStructure.GPIO_Speed=GPIO_Speed_2MHz;
	GPIO_Init(GPIOG,&GPIO_InitStructure);        //PG6引脚输出模式，默认输出高电平 #SHDN 5V开关 (3VCC->5VA)
	GPIO_SetBits(GPIOG,GPIO_Pin_6); 
	
	GPIO_InitStructure.GPIO_Pin=GPIO_Pin_9;
	GPIO_Init(GPIOB,&GPIO_InitStructure);				 //PB9    控制电导率电源  输出高电平（VB->4V）
	GPIO_SetBits(GPIOB,GPIO_Pin_9);
	
	GPIO_InitStructure.GPIO_Pin=GPIO_Pin_8;
	GPIO_Init(GPIOD,&GPIO_InitStructure);				 //PD8    ADS1262 #RESET 输出高电平
	GPIO_SetBits(GPIOD,GPIO_Pin_8);
	
	GPIO_InitStructure.GPIO_Pin=GPIO_Pin_3;
	GPIO_Init(GPIOA,&GPIO_InitStructure);
//	GPIO_ResetBits(GPIOA,GPIO_Pin_3);
//	delay_ms(500);										//PA3    DS3231  RESET  输出高电平
	GPIO_SetBits(GPIOA,GPIO_Pin_3);
	//delay_us(20);
	
	GPIO_InitStructure.GPIO_Pin=GPIO_Pin_7;
	GPIO_Init(GPIOC,&GPIO_InitStructure);       		 //PC7   引脚输出模式，控制与门总开关，默认低电平
	GPIO_ResetBits(GPIOC,GPIO_Pin_7);
	
	GPIO_InitStructure.GPIO_Pin=GPIO_Pin_8;
	GPIO_Init(GPIOA,&GPIO_InitStructure);				 //PA8    控制压力测量电源，默认关闭，测量时打开 输出低电平
	GPIO_SetBits(GPIOA,GPIO_Pin_8);
	
	GPIO_InitStructure.GPIO_Pin=GPIO_Pin_9;
	GPIO_Init(GPIOD,&GPIO_InitStructure);				 //PD9     ADS1262  Y   输出低电平
	GPIO_ResetBits(GPIOD,GPIO_Pin_9);
	
	GPIO_InitStructure.GPIO_Pin=GPIO_Pin_10;
	GPIO_Init(GPIOD,&GPIO_InitStructure);				 //PD10     ADS1262  MCLK IN  输出低电平
	
	GPIO_InitStructure.GPIO_Pin=GPIO_Pin_9;
	GPIO_Init(GPIOC,&GPIO_InitStructure);				 //PC9     ADS1262  START 输出

	GPIO_InitStructure.GPIO_Pin=GPIO_Pin_4;
	GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN;
	GPIO_Init(GPIOG,&GPIO_InitStructure);				 //PG4 ADS1262 DRDY 数据准备就绪信号 输入
	
	GPIO_InitStructure.GPIO_Pin=GPIO_Pin_6;
	GPIO_Init(GPIOC,&GPIO_InitStructure);                //PC6 电导率频率捕获 输入
	
}


/*------------------------------电源控制----------------------------*/
void PowerControl(unsigned char state)
{
	if (state==1)
	{
		GPIO_SetBits(GPIOC,GPIO_Pin_7);									//开启测量总电源
		GPIO_SetBits(GPIOB,GPIO_Pin_9);									//给压力、电导率测量模块供电
		GPIO_SetBits(GPIOA,GPIO_Pin_8);									//给压力激励源模块供电	
	}
	else
	{
		GPIO_ResetBits(GPIOC,GPIO_Pin_7);								//关闭温度测量用电源
		GPIO_ResetBits(GPIOB,GPIO_Pin_9);								//关闭压力，电导率测量模块电源
		GPIO_ResetBits(GPIOA,GPIO_Pin_8);								//关闭压力激励源模块
	}
}
/*------------------------------电源控制----------------------------*/
/***********************************
 *上传数据
 * *********************************/
void SendData(void)
{
	        //发送时间
			Usart_SendString(DEBUG_USART,"Time=");
            UART_485_232SendMsg(Day,Mon,TxYear,TxHour,TxMinu,TxSec);
	        Usart_SendString(DEBUG_USART,(char *)"\r\n");
	
            //发送温度
			Usart_SendString(DEBUG_USART,"Tem=");
            Usart_SendStr_length(DEBUG_USART,(char *)fdasc(TemUploadFloat, UploadchTem),8);
            Usart_SendString(DEBUG_USART,(char *)",");
            Usart_SendString(DEBUG_USART,(char *)"\t");

           //发送电导率
			Usart_SendString(DEBUG_USART,"Con=");
            Usart_SendStr_length(DEBUG_USART,(char *)fdasc2(ConUploadFloat, UploadchCond),7);
            Usart_SendString(DEBUG_USART,(char *)",");
            Usart_SendString(DEBUG_USART,(char *)"\t");

            //发送压力
			Usart_SendString(DEBUG_USART,"Pre=");
            Usart_SendStr_length(DEBUG_USART,(char *)fdasc3(Pres, chPre),8);
            Usart_SendString(DEBUG_USART,(char *)",");
            Usart_SendString(DEBUG_USART,(char *)"\t");
	
	        Usart_SendString(DEBUG_USART,(char *)"\r\n");

//            //发送电阻
			Usart_SendString(DEBUG_USART,"R=");
            Usart_SendStr_length(DEBUG_USART,(char *)fdascR(R_average1, UploadchRes),8);
            Usart_SendString(DEBUG_USART,(char *)",");
            Usart_SendString(DEBUG_USART,(char *)"\t");

//            //发送频率
			Usart_SendString(DEBUG_USART,"Fre=");
            Usart_SendStr_length(DEBUG_USART,(char *)fdasc3(FreUploadFloat, UploadchFreq),8);
            Usart_SendString(DEBUG_USART,(char *)",");
            Usart_SendString(DEBUG_USART,(char *)"\t");

            //发送电压
			Usart_SendString(DEBUG_USART,"U=");
            Usart_SendStr_length(DEBUG_USART,(char *)fdascU(PreU, chPreU),7);
            Usart_SendString(DEBUG_USART,(char *)",");
            Usart_SendString(DEBUG_USART,(char *)"\t");


            Usart_SendString(DEBUG_USART,(char *)"\r\n");

}

/***********************************
// 温度结果ASCII码转换
//温度格式 温度转换,***.****
//温度范围-20-100
***********************************/
float abs1(float Num)
{
    if(Num>0)
        return Num;
    else
        return -Num;
}


unsigned char *fdasc(float Input,unsigned char AsciiT[8])
{
 unsigned char Ascii[8];
 int32_t ZhengShu,XiaoShu;
 if(Input>0)
 {
    ZhengShu=floor(Input);

    XiaoShu=(int32_t)((Input-ZhengShu)*10000+0.5);

    if(Input<100.)
    {
        Ascii[4]='.';

        if(ZhengShu/10)
        {
         Ascii[5]=(char)((ZhengShu%10)+0x30);
         Ascii[6]=(char)((ZhengShu/10)+0x30);
         Ascii[7]=' ';
        }

        else
        {
            Ascii[5]=(char)(ZhengShu+0x30);
            Ascii[6]=Ascii[7]=' ';
        }

                    Ascii[3]=(char)(XiaoShu/1000+0x30);
                    Ascii[2]=(char)((XiaoShu/100)%10+0x30);
                    Ascii[1]=(char)((((XiaoShu/10)%100)%10)+0x30);
                    Ascii[0]=(char)(XiaoShu%10+0x30);


    }

    else
    {
        Ascii[7]=0x01+0x30;
        Ascii[6]=0x30;
        Ascii[5]=0x30;
        Ascii[4]='.';
        Ascii[3]=0x30;
        Ascii[2]=0x30;
        Ascii[1]=0x30;
        Ascii[0]=0x30;
    }

 }

 if((Input<0)&(abs1(Input)<20))
 {

      Ascii[4]='.';

        Input=abs1(Input);

      ZhengShu=floor(Input);

        XiaoShu=(int32_t)((Input-ZhengShu)*10000+0.5);

      if(ZhengShu/10)
        {
         Ascii[5]=(char)((ZhengShu%10)+0x30);
         Ascii[6]=(char)((ZhengShu/10)+0x30);
         Ascii[7]='-';
        }

        else
        {
            Ascii[5]=(char)(ZhengShu+0x30);
            Ascii[7]=' ';
            Ascii[6]='-';
        }
             Ascii[3]=(char)(XiaoShu/1000+0x30);
             Ascii[2]=(char)((XiaoShu/100)%10+0x30);
             Ascii[1]=(char)((((XiaoShu/10)%100)%10)+0x30);
             Ascii[0]=(char)(XiaoShu%10+0x30);
 }

 if(Input<= -20)
 {
            Ascii[7]='-';
            Ascii[6]=0x30+0x02;
            Ascii[5]=0x30;
            Ascii[4]='.';
            Ascii[3]=0x30;
            Ascii[2]=0x30;
            Ascii[1]=0x30;
            Ascii[0]=0x30;
 }
 AsciiT[0]=Ascii[7];
 AsciiT[1]=Ascii[6];
 AsciiT[2]=Ascii[5];
 AsciiT[3]=Ascii[4];
 AsciiT[4]=Ascii[3];
 AsciiT[5]=Ascii[2];
 AsciiT[6]=Ascii[1];
 AsciiT[7]=Ascii[0];
return AsciiT;
}

/**********************************
//电导率结果ASCII码转换
//电导率格式 *.*****
//电导率范围 0-7
***********************************/
unsigned char *fdasc2(float Input,unsigned char AsciiT[7])
{
    unsigned char Ascii[7];
    int32_t ZhengShu,XiaoShu;
    ZhengShu=floor(Input);

    XiaoShu=(int32_t)((Input-ZhengShu)*100000+0.5);

    if(Input>0)
    {
        Ascii[5]='.';
        Ascii[6]=(char)(ZhengShu+0x30);
        Ascii[4]=(char)(XiaoShu/10000+0x30);
        Ascii[3]=(char)((XiaoShu/1000)%10+0x30);
        Ascii[2]=(char)((((XiaoShu/100)%100)%10)+0x30);
        Ascii[1]=(char)((((XiaoShu/10)%1000)%100)%10+0x30);
    Ascii[0]=(char)(XiaoShu%10+0x30);
    }

    else
    {
        Ascii[0]=0x30;
        Ascii[6]=0x30;
        Ascii[4]=0x30;
        Ascii[5]='.';
        Ascii[3]=0x30;
        Ascii[2]=0x30;
        Ascii[1]=0x30;

    }
     AsciiT[0]=Ascii[6];
     AsciiT[1]=Ascii[5];
     AsciiT[2]=Ascii[4];
     AsciiT[3]=Ascii[3];
     AsciiT[4]=Ascii[2];
     AsciiT[5]=Ascii[1];
     AsciiT[6]=Ascii[0];

    return AsciiT;
}

/**********************************
//压力传感器电压结果ASCII码转换
//电压格式 *.*****
//电导率范围 0~3.8V
***********************************/
unsigned char *fdascU(float Input,unsigned char AsciiT[7])
{
    unsigned char Ascii[7];
    int32_t ZhengShu,XiaoShu;
    ZhengShu=floor(Input);

    XiaoShu=(int32_t)((Input-ZhengShu)*100000+0.5);

    if(((Input<3.8)|(Input==3.8))&(Input>0))
    {
        Ascii[5]='.';
        Ascii[6]=(char)(ZhengShu%10+0x30);
        Ascii[4]=(char)((XiaoShu/10000)%10+0x30);
        Ascii[3]=(char)((XiaoShu/1000)%10+0x30);
        Ascii[2]=(char)((XiaoShu/100)%10+0x30);
        Ascii[1]=(char)((XiaoShu/10)%10+0x30);
        Ascii[0]=(char)(XiaoShu%10+0x30);
    }

    else
    {
        Ascii[6]=0x30;
        Ascii[5]='.';
        Ascii[4]=0x30;
        Ascii[3]=0x30;
        Ascii[2]=0x30;
        Ascii[1]=0x30;
        Ascii[0]=0x30;

    }
     AsciiT[0]=Ascii[6];
     AsciiT[1]=Ascii[5];
     AsciiT[2]=Ascii[4];
     AsciiT[3]=Ascii[3];
     AsciiT[4]=Ascii[2];
     AsciiT[5]=Ascii[1];
     AsciiT[6]=Ascii[0];
    return AsciiT;
}


/*****************************************************************************
//压力结果ASCII码转换
//压力格式 ****.***
//压力范围 0-7000
*****************************************************************************/

unsigned char *fdasc3(float Input,unsigned char AsciiT[8])
{
    unsigned char Ascii[8];
    int32_t ZhengShu,XiaoShu;

    ZhengShu=floor(Input);

    XiaoShu=(int32_t)((Input-ZhengShu)*1000+0.5);

    if((Input<7000.)&(Input>0))
    {
        Ascii[3]='.';

        if(ZhengShu/1000)
        {
            Ascii[7]=(char)(ZhengShu/1000+0x30);
            Ascii[6]=(char)((ZhengShu%1000)/100+0x30);
            Ascii[5]=(char)(((ZhengShu%1000)%100)/10+0x30);
            Ascii[4]=(char)((ZhengShu%10)+0x30);
        }

        if((ZhengShu<1000.)&((ZhengShu==100)|(ZhengShu>100)))
        {
            Ascii[7]=' ';
            Ascii[6]=(char)(ZhengShu/100+0x30);
            Ascii[5]=(char)((ZhengShu%100)/10+0x30);
            Ascii[4]=(char)((ZhengShu%10)+0x30);
        }

        if((ZhengShu<100.)&((ZhengShu>10)|(ZhengShu==10)))
        {
            Ascii[7]=Ascii[6]=' ';
            Ascii[5]=(char)((ZhengShu/10)+0x30);
            Ascii[4]=(char)((ZhengShu%10)+0x30);

        }

        if(ZhengShu<10)
        {
            Ascii[7]=Ascii[6]=Ascii[5]=' ';
            Ascii[4]=(char)((ZhengShu%10)+0x30);
        }

          Ascii[2]=(char)((XiaoShu/100)+0x30);
          Ascii[1]=(char)((XiaoShu/10)%10+0x30);
          Ascii[0]=(char)(XiaoShu%10+0x30);

    }
    else
       if((Input<0)|(Input==0))
       {
          Ascii[0]=0x30;
          Ascii[6]=0x30;
          Ascii[4]=0x30;
          Ascii[3]='.';
          Ascii[5]=0x30;
          Ascii[2]=0x30;
          Ascii[1]=0x30;
          Ascii[7]=0x30;
       }
       else
       {
          Ascii[0]=0x30;
          Ascii[6]=0x30;
          Ascii[4]=0x30;
          Ascii[3]='.';
          Ascii[5]=0x30;
          Ascii[2]=0x30;
          Ascii[1]=0x30;
          Ascii[7]=0x37;

       }
    AsciiT[0]=Ascii[7];
    AsciiT[1]=Ascii[6];
    AsciiT[2]=Ascii[5];
    AsciiT[3]=Ascii[4];
    AsciiT[4]=Ascii[3];
    AsciiT[5]=Ascii[2];
    AsciiT[6]=Ascii[1];
    AsciiT[7]=Ascii[0];
    return AsciiT;
}

/***********************************
 * 浮点数到十六进制数的转换
 * *********************************/
int32_t floattohex(float hex)
{
    return*(int32_t*)&hex;
}


/************************************************************
    函数名     fdascR
    功能      将电阻值转换为ASCII码值
    输入参数
    输出参数
    调用
    变量
************************************************************
*/
unsigned char *fdascR(double Input,unsigned char AsciiT[8])
{
  long long int XiaoShu,ZhengShu;
    unsigned char Ascii[8];
    ZhengShu=floor(Input);

    XiaoShu=(int64_t)((Input-ZhengShu)*1000000);

    if(((Input<10.)|(Input==10.))&(Input>0))
    {
        Ascii[6]='.';
        Ascii[7]=(char)(ZhengShu+0x30);
        Ascii[5]=(char)(XiaoShu/100000+0x30);
        Ascii[4]=(char)((XiaoShu/10000)%10+0x30);
        Ascii[3]=(char)((((XiaoShu/1000)%100)%10)+0x30);
        Ascii[2]=(char)((((XiaoShu/100)%1000)%100)%10+0x30);
        Ascii[1]=(char)(((((XiaoShu/10)%10000)%1000)%100)%10+0x30);
    Ascii[0]=(char)(XiaoShu%10+0x30);
    }

    else
    {
        Ascii[0]=0x30;
        Ascii[6]='.';
        Ascii[4]=0x30;
        Ascii[5]=0x30;
        Ascii[7]=0x30;
        Ascii[3]=0x30;
        Ascii[2]=0x30;
        Ascii[1]=0x30;

    }
        AsciiT[0]=Ascii[7];
        AsciiT[1]=Ascii[6];
        AsciiT[2]=Ascii[5];
        AsciiT[3]=Ascii[4];
        AsciiT[4]=Ascii[3];
        AsciiT[5]=Ascii[2];
        AsciiT[6]=Ascii[1];
        AsciiT[7]=Ascii[0];

    return AsciiT;
}

void UART_485_232SendMsg(int xDay,int xMon,int *xYear,int *xHour,int *xMinu,int *xSec)
{
    int countY,countH,countM,countS,Month;
    countY=countH=countM=countS = 0;
    if(xMon<10)
	{
       Month=xMon;
	}
    else
	{
      Month=xMon-6;
	}
    //发送日期
/*    while(countD<2)countD,countD=
    {
        while (!(UC1IFG & UCA1TXIFG));                // USART1 TX buffer ready?
        UCA1TXBUF = xDay[countD];                       //数据写入发送data BUF*************************************************************************
        Datetime[countD]=xDay[countD];              //Datetime[ ]什么作用？？？？？？？？？？
        countD++;
    }
*/
    switch(xDay)
    {
    case 0x01:Usart_SendString(DEBUG_USART,"01");break;
    case 0x02:Usart_SendString(DEBUG_USART,"02");break;
    case 0x03:Usart_SendString(DEBUG_USART,"03");break;
    case 0x04:Usart_SendString(DEBUG_USART,"04");break;
    case 0x05:Usart_SendString(DEBUG_USART,"05");break;
    case 0x06:Usart_SendString(DEBUG_USART,"06");break;
    case 0x07:Usart_SendString(DEBUG_USART,"07");break;
    case 0x08:Usart_SendString(DEBUG_USART,"08");break;
    case 0x09:Usart_SendString(DEBUG_USART,"09");break;
    case 0x10:Usart_SendString(DEBUG_USART,"10");break;
    case 0x11:Usart_SendString(DEBUG_USART,"11");break;
    case 0x12:Usart_SendString(DEBUG_USART,"12");break;
    case 0x13:Usart_SendString(DEBUG_USART,"13");break;
    case 0x14:Usart_SendString(DEBUG_USART,"14");break;
    case 0x15:Usart_SendString(DEBUG_USART,"15");break;
    case 0x16:Usart_SendString(DEBUG_USART,"16");break;
    case 0x17:Usart_SendString(DEBUG_USART,"17");break;
    case 0x18:Usart_SendString(DEBUG_USART,"18");break;
    case 0x19:Usart_SendString(DEBUG_USART,"19");break;
    case 0x20:Usart_SendString(DEBUG_USART,"20");break;
    case 0x21:Usart_SendString(DEBUG_USART,"21");break;
    case 0x22:Usart_SendString(DEBUG_USART,"22");break;
    case 0x23:Usart_SendString(DEBUG_USART,"23");break;
    case 0x24:Usart_SendString(DEBUG_USART,"24");break;
    case 0x25:Usart_SendString(DEBUG_USART,"25");break;
    case 0x26:Usart_SendString(DEBUG_USART,"26");break;
    case 0x27:Usart_SendString(DEBUG_USART,"27");break;
    case 0x28:Usart_SendString(DEBUG_USART,"28");break;
    case 0x29:Usart_SendString(DEBUG_USART,"29");break;
    case 0x30:Usart_SendString(DEBUG_USART,"30");break;
    case 0x31:Usart_SendString(DEBUG_USART,"31");break;
    default:break;
    }

    Usart_SendString(DEBUG_USART," ");
    //发送月
    switch(xMon)
    {
    case 0x01:Usart_SendString(DEBUG_USART,"Jan");break;
    case 0x02:Usart_SendString(DEBUG_USART,"Feb");break;
    case 0x03:Usart_SendString(DEBUG_USART,"Mar");break;
    case 0x04:Usart_SendString(DEBUG_USART,"Apr");break;
    case 0x05:Usart_SendString(DEBUG_USART,"May");break;
    case 0x06:Usart_SendString(DEBUG_USART,"Jun");break;
    case 0x07:Usart_SendString(DEBUG_USART,"July");break;
    case 0x08:Usart_SendString(DEBUG_USART,"Aug");break;
    case 0x09:Usart_SendString(DEBUG_USART,"Sep");break;
    case 0x10:Usart_SendString(DEBUG_USART,"Oct");break;
    case 0x11:Usart_SendString(DEBUG_USART,"Nov");break;
    case 0x12:Usart_SendString(DEBUG_USART,"Dec");break;
    default:break;
    }
    Datetime[2]=*g_ppcMonth[Month-1];           //
    Datetime[3]=*(g_ppcMonth[Month-1]+1);       //
    Datetime[4]=*(g_ppcMonth[Month-1]+2);       //
    Usart_SendString(DEBUG_USART," ");
    //发送年
    while(countY<4)
    {
                
        Usart_SendByte (DEBUG_USART, xYear[countY]);                       //数据写入发送data BUF***********************************************************************
        Datetime[5+countY]=xYear[countY];
        countY++;
    }
    Usart_SendString(DEBUG_USART,",  ");
    //发送时
    while(countH<2)
    {
        Usart_SendByte (DEBUG_USART, xHour[countH]);                       //数据写入发送data BUF***********************************************************************
        Datetime[9+countH]=xHour[countH];
        countH++;
    }
    Usart_SendString(DEBUG_USART,":");
    //发送分
    while(countM<2)
    {
         Usart_SendByte (DEBUG_USART, xMinu[countM]);                       //数据写入发送data BUF***********************************************************************
        Datetime[11+countM]=xMinu[countM];
        countM++;
    }
    Usart_SendString(DEBUG_USART,":");
    //发送秒
    while(countS<2)
    {
         Usart_SendByte (DEBUG_USART, xSec[countS]);                       //数据写入发送data BUF***********************************************************************
        Datetime[13+countS]=xSec[countS];
        countS++;
    }

    Usart_SendString(DEBUG_USART,"\r");
}

